#ifndef xpack_eowz_bool_value
#define xpack_eowz_bool_value
#pragma push_macro("xuser")
#undef  xuser
#define xuser mixc::eowz_bool_value::inc
#include"define/base_type.hpp"
#include"macro/xexport.hpp"
#include"instruction/count_of_set.hpp"
#pragma pop_macro("xuser")

namespace mixc::eowz_bool_value::origin{
    template<class item_t>
    struct bool_value{
    private:
        item_t value = item_t(-1);
    public:
        operator bool(){
            // 当置位位为偶数时表示 false
            // value 最初值为所有位都为 1，置位位为偶数，所以默认表示的值是 false
            return (inc::count_of_set(value) & 1) == 0;
        }

        bstate_t toggle(){
            if (value == 0){
                return bstate_t::fail;
            }
            else{
                value         <<= 1;
                return bstate_t::success;
            }
        }
    };
}

#endif

xexport_spacex(eowz, mixc::eowz_bool_value::origin)
